<?php
/**
 * WB_S3Base class
 * 
 * @author Jean-Lou Dupont
 * @version @@package-version@@
 * @id $Id: S3Base.php 141 2008-03-14 18:02:19Z jldupont $
 */

 //{{include
 
 //include}}
 
 class WB_S3Base
	implements Iterator 
 {
	/**
	 * The list formatted with
	 * bucket/object names as keys
	 */
	var $liste = array();	
	
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%		
	// PUBLIC interface
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%				
	/**
	 * Returns the existence status
	 * for a given bucket name.
	 * 
	 * @return boolean
	 * @param $name string
	 */
	public function exists( $name )
	{
		return isset( $this->liste[ $name ] );		
	}
	/**
	 * Wildcard getter
	 * 
	 * @return mixed
	 * @param $name string
	 */
	public function __get( $name )
	{
		return @$this->liste[ $name ] ;
	}
	/**
	 * Wildcard setter
	 * 
	 * @return $this
	 * @param $name string
	 * @param $value mixed
	 */
	public function __set( $name, $value )
	{
		@$this->liste[ $name ] = $value ;
		return $this;
	}
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%		
	// PUBLIC ITERATOR Interface
	//   key         => value
	//   bucket name => creation_date
	// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%				
	public function rewind() 
	{
		reset($this->liste);
	}
	
	public function current() 
	{
		$var = current($this->liste);
		return $var;
	}
	
	public function key() 
	{
		$var = key($this->liste);
		return $var;
	}
	
	public function next() 
	{
		$var = next($this->liste);
		return $var;
	}
	
	public function valid() 
	{
		$var = $this->current() !== false;
		return $var;
	}
	
 } // end class declaration